import {
  addPlayerType,
  pageType,
  playerResponseType,
  playerParamsType,
} from "@/types/vote";
import { http } from "@/utils/request";

// 发布投票
export const addPlayerAPI = (data: addPlayerType) => {
  return http<string>({
    method: "POST",
    url: "/api/v1/activity/add",
    data,
  });
};

// 发布投票
export const getPlayerListAPI = (data: playerParamsType) => {
  return http<pageType<playerResponseType>>({
    method: "POST",
    url: "/api/v1/activity/all",
    data,
  });
};

//给选手投票
export const votePlayerAPI = (playerId: string) => {
  return http<string>({
    method: "GET",
    url: `/api/v1/activity/vote`,
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data: {
      id: playerId,
    },
  });
};

//修改选手信息
export const updatePlayerAPI = (data: addPlayerType) => {
  return http<string>({
    method: "POST",
    url: "/api/v1/activity/modify/candidate", //修改选手信息
    data,
  });
};

//删除选手信息
export const deletePlayerAPI = (playerId: string) => {
  return http<string>({
    method: "GET",
    url: "/api/v1/activity/delete/candidate", //删除选手信息
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data: {
      id: playerId,
    },
  });
};

//审核通过选手信息
export const auditPlayerAPI = (playerId: string) => {
  return http<string>({
    method: "GET",
    url: "/api/v1/activity/audit/approve", //审核通过选手信息
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data: {
      id: playerId,
    },
  });
};

//拒绝通过选手信息
export const rejectPlayerAPI = (playerId: string, cause: string) => {
  return http<string>({
    method: "GET",
    url: "/api/v1/activity/audit/reject", //拒绝通过选手信息
    header: {
      "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
    },
    data: {
      id: playerId,
      cause,
    },
  });
};
